home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
EDUCATE
/
SM20A.ARJ
/
SYMBMATH.DO2
< prev
next >
Wrap
Text File
|
1992-04-12
|
47KB
|
1,606 lines
SymbMath 2.0: A Symbolic Calculator with Learning
(Version 2.0)
Copyright (C) 1990-1992
by Dr. Weiguang HUANG
5/6 Cara Road, Geelong, Vic. 3216, Australia
Phone: (052)443282
This is Part Two of manual. Please read Part One in the file
SymbMath.DOC.
15. Examples
In following examples, a line "Input:" means to type the
program in Editor, then to select the command "Run", while a
line "Output:" means output in the "Output" window. # is a comment
statement.
15.1 Assumption and Simplification
SymbMath automatically simplifies the output expression.
Users can further simplify it by typing "last" again and again until
they are happy.
Example: reduce sqrt(x^2).
Input:
sqrt(x^2)
Output:
x*sgn(x)
A first way to reduce this output expression is to substitute
sgn(x) by 1 if x is positive.
Input:
subs(sgn(x)=1 to last)
Output:
x
A second way to reduce the output expression is to assume
x>0 before evaluation. On this way, all x is affected. The first
method is local simplification, but the second method is global
simplification. If users declare the variable x is positive or
negative by
assume(x > 0)
assume(x < 0)
the output expression is more simpler than that if users do not
declare it.
Example:
Input:
assume(x >0)
sqrt(x^2)
Output:
x
Users can assume the variable is real by
assume(b == real)
Example:
Input:
assume(b == real)
sqrt(b^2)
Output:
abs(b)
All variables are complex by default.
Example: set f1=x^2+y^3, then put f1 into sin(f1)+
cos(2*f1).
Input:
f1=x^2+y^3
z=sin(f1)+cos(2*f1)
z
Output:
f1 = x^2 + y^3
z = sin(f1) + cos (2 f1)
sin(x^2 + y^3) + cos(2 (x^2 + y^3))
Example: save the above result to f2 and display.
Input:
f2=last
f2
Output:
sin(x^2 + y^3) + cos(2*(x^2 + y^3))
where a special word "last" stands for the last output, e.g. here
"last" is sin(x^2+y^3)+cos(2*(x^2+y^3)).
15.2 Calculation
SymbMath gives the exact value of calculation when the switch
Numerical=Off (default), or the approximate value of calculation when
the switch Numerical=On.
SymbMath can manipulate units as well as numbers, be used as
a symbolic calculator, and do exact computation. The range of numbers
is from -infinity to infinity, e.g. ln(-inf), exp(inf+pi*i), etc.
SymbMath contains many built-in algorithms for performing numerical
calculations when the switch Numerical=On, e.g. ln(-9), i^i,
(-2.3)^(-3.2), 2^3^4^5^6^7^8^9, etc.
Warming that SymbMath only gives a principle value if there
are multi-values, except for the function solve().
Example: find the exact values of sin(x) when x=pi/4 and
x=45 degree.
Input:
sin(pi/4)
deg=pi/180
sin(45*deg)
Output:
2^(-0.5)
deg = pi/180
2^(-0.5)
Example: set the units converter from the minute to the
second, then calculate numbers with different units.
Input:
minute=60*second
v=2*meter/second
t=2*minute
d0=10*meter
v*t+d0
Output:
250 meter
15.3 User-defined Function and Evaluation
Users can define a new function by
define(f(x)=x^2)
the right hand side of "=" includes the standard functions, calculus
functions, and algebraic operators.
Example: define a new function f(x,y)=sqrt(x^2+y^2), then
evaluate z when x=1 and y=2, and when x=3 and y=4.
Input:
define(f(x,y)=sqrt(x^2+y^2))
f(1,2)
f(3,4)
Output:
defined
sqrt(5)
5
Example: assign sqrt(x^2+y^2) to z, then evaluate z when x=1
and y=2, and when x=3 and y=4.
Input:
z=sqrt(x^2+y^2)
subs(x=1,y=2,z)
subs(x=3,y=4,z)
Output:
z = sqrt(x^2 + y^2)
sqrt(5)
5
Note that after evaluation, x and y should be cleared from
memory by clear(x) and clear(y) before differentiation of the new
function. Otherwise all of x and y still are 3 and 4 until new values
assigned. If only one variable in subs(), this variable is
automatically cleared after evaluation. This rule applies to other
functions.
15.4 Limits
SymbMath finds real or complex limits, and discontinuity
when x approaches to c by functions
subs(x=c to f(x))
lim(x=c, f(x))
First use subs() to find limits, if the result is undefined
(indeterminate forms, e.g. 0/0, inf/inf, 0*inf, and 0^0), then use
lim() to try again; if the result is discont, then use the one-side
limit by c+zero or c-zero.
Example: find limits of types 0/0 and inf/inf.
Input:
p=(x^2-4)/(2*x-4)
subs(x=2 to p)
lim(x=2, p)
subs(x=inf to p)
lim(x=inf, p)
Output:
p = (x^2 - 4)/(2 x - 4)
undefined
2
undefined
inf
The "discont" (discontinuity) means that the expression has
a discontinuity and only has the one-sided limit value at x=c. Users
should use c+zero or c-zero to find one-sided limit. The f(c+zero) or
f(c-zero) is the right-sided limit or left-sided limit as approaching
c from positive (+inf) or negative (-inf) direction, respectively,
i.e. limit as zero -> 0.
SymbMath find left-sided limit or right-sided limit when x
approaches to c from positive (+inf) or negative (-inf) direction at
discontinuity by functions
subs(x=c+zero to f(x))
subs(x=c-zero to f(x))
lim(x=c+zero, f(x))
lim(x=c-zero, f(x))
Example: find left-sided and right-sided limits of y=exp(1/x),
(i.e. when x approaches 0 from positive and negative directions).
Input:
y=exp(1/x)
subs(x=0 to y)
subs(x=0+zero to y)
subs(x=0-zero to y)
Output:
y = exp(1/x)
discont
inf
0
The built-in constants of inf or -inf, zero or -zero, and
discont or undefined can be used as numbers in calculation of
expressions or functions.
input:
1/sgn(0)
1/sgn(zero)
output:
discont
1
15.5 Differentiation
SymbMath differentiates an expression expr by functions
d(expr / d(x))
d(expr / d(x), order)
d(expr, x=c)
d(expr, x=c, order)
Example: differentiate the expression f=sin(x^2+y^3)+
cos(2*(x^2+y^3)) with respect to x, and with respect to both x and y.
Input:
f=sin(x^2+y^3)+cos(2*(x^2+y^3))
d(f /d(x))
d(d(f/d(x))/d(y))
Output:
f = sin(x^2 + y^3) + cos(2*(x^2 + y^3))
2*x*cos(x^2 + y^3) - 4*x*sin(2*(x^2 + y^3))
-6*x*y^2*sin(x^2 + y^3) - 12*x*y^2*cos(2*(x^2 + y^3))
15.6 Integration
SymbMath finds integrals by functions
inte(expr * d(x))
inte(expr, variable from a to b)
The library Integral.Li should be read from a disk before formal
integration so that it become more powerful on integration. It is better
to expand the integrand by the function expand() before formal
integration.
If formal integration fails, numerical integration is used
when users set the switch NumIntegate=On.
15.6.1 Indefinite Integration
Example: find indefinite integrals.
Input:
inte(sinh(x)^2*e^sinh(x)*cosh(x)*d(x))
Output:
constant - 2 (-exp(sinh(x)) + sinh(x)*exp(sinh(x))) + sinh(x)^2*exp(sinh(x))
Input:
inte(sinh(x)^2*cosh(x)*d(x))
Output:
constant + (1/3)*sinh(x)^3
Example: find indefinite double integrals.
Input:
inte(inte(x*y*d(x))*d(y))
Output:
constant + Constant*y + (1/4)*x^2*y^2
Example: find the line integral.
Input:
x=2*t
y=3*t
z=5*t
u=x+y
v=x-y
w=x+y+z
inte((u*d(u/d(t))+v*d(v/d(t))+w*d(w/d(t)) * d(t))
Output:
63*t^2
Example: find the integral of ln(x)^6/x by the mean of the
library Integral.Li. First run Integral.Li, then
Input:
inte(ln(x)^n/x*d(x))
subs(n=6, last)
Output:
ln(x)^(1+n)/(1+n)
(1/7)*ln(x)^7
15.6.2 Definite Integration
Example: find the definite integral of y=exp(1-x) with
respect to x taken from x=0 to x=infinity.
Input:
inte(exp(1-x), x from 0 to inf)
Output:
e
Example: compare numerical integration and symbolic
integration for y=4/(1+x^2) with respect to x taken from x=0 to x=1.
Input:
NumIntegrate=On
y=4/(1+x^2)
inte(y, x from 0 to 1)
Output:
3.1415
Input:
NumIntegrate=Off
y=4/(1+x^2)
inte(y, x from 0 to 1)
Output:
pi
Input:
Numerical=On
pi
Output:
3.1416
Example: discontinuous integration of 1/x and 1/x^2 with
discontinuity at x=0.
Input:
inte(1/x, x from -1 to 2)
Output:
ln(2)
Input:
inte(1/x^2, x from -1 to 0-zero) + inte(1/x^2, x from 0+zero to 2)
Output:
inf
15.7 Algebraic Equations
The equations can be operated (e.g. +, -, *, /, ^, expand(),
diff(), inte()). The operation is on both sides of the equation, as
by hand. SymbMath is able to find roots of a polynomial, algebraic
equations, systems of equations, differential and integral equations.
Example: solve an equation
sqrt(x+2*k) - sqrt(x-k) == sqrt(k),
then check the solution by substituting the root into the equation.
Input:
eq1=(sqrt(x + 2*k) - sqrt(x - k) == sqrt(k))
eq1^2
expand(last)
last-k-2*x
last/(-2)
last
last^2
expand(last)
last-x^2+2*k
last/k
subs(x=right(last) to eq1)
Output:
eq1=(sqrt(x + 2*k) - sqrt(x - k) == sqrt(k))
((2*k + x)^0.5 - ((-k) + x)^0.5)^2 == k
2*x + k + (-2)*(2*k + x)^0.5*((-k) + x)^0.5 == k
(-2)*(2*k + x)^0.5*((-k) + x)^0.5 == (-2)*x
(1/1)*(2*k + x)^0.5*((-k) + x)^0.5 == (1/1)*x
(2*k + x)^0.5*((-k) + x)^0.5 == x
(2*k + x)*((-k) + x) == x^2
(-2)*k^2 + k*x + x^2 == x^2
k*x == 2*k^2
x == 2*k
k^0.5 == k^0.5
SymbMath can solve many algebraic equations step by step, as
by hand. This method is useful on teaching, e.g. to show students how
to solve equations.
SymbMath has the built-in function
solve(expr1 == expr2, x)
solve([expr1 == expr2, expr3 == expr4], [x, y])
to solve a polynomial and systems of linear equations on one step.
All of the real and complex roots of the equation will be found.
The function solve() outputs a list of roots when there are multi-
roots. Users can get one of roots from the list, (see the later
chapter "List and Array").
Users can get one side of the equation by the functions
left(left_side==right_side)
for the left side, and
right(left_side==right_side)
for the right side.
Example: solve a+b*x+x^2 == 0, save the root to x, find the
value of x when a=3 and b=4.
Input:
eq1=(a+b*x+x^2==0)
solve(eq1, x)
right(last)
x=last
a=3, b=4
x[1]
x[2]
Output:
eq1=(a+b*x+x^2==0)
x == [-b/2 + sqrt((b/2)^2 - a), -b/2 - sqrt((b/2)^2 - a)]
[-b/2 + sqrt((b/2)^2 - a), -b/2 - sqrt((b/2)^2 - a)]
x=
a=3, b=4
-1
-3
Note that after assignment of 3 to the variable "a" by "=",
the variable "a" still is 3 in all expressions until new value
assigned, and cannot be automatically cleared from memory. This is
different from subs().
Function solve() not only solve for a simple variable x
but also for an unknown function, e.g. ln(x).
Input:
solve(1+ln(x)+ln(x)^2==0, ln(x))
exp(last)
Output:
ln(x) ==
x ==
Input:
f=[x+y==3+a+b, x-y==1+a-b], [x,y])
solve(f, [x,y])
solve(f, [a,b])
solve(f, [a,y])
solve(f, [x,b])
Output:
f = [x + y == 3 + a + b, x - y == 1 + a - b]
[x == -(1/2)*(-4 - 2 a), y == -(1/2)*(-2 - 2 b)]
[a == -(1/2)*(4 - 2 x), b == -(1/2)*(2 - 2 y)]
[b == -(1/2)*(2 - 2 y), x == -(1/2)*(-4 - 2 a)]
[a == (1/2)*(-4 + 2 x), y == (1/2)*(2 + 2 b)]
15.8 Differential and Integral Equations
SymbMath can solve separable differential equations
f(x)*d(x)+g(y)*d(y) == f2(x)*d(x)+g2(y)*d(y),
g(y)*d(d(y)/d(x))/d(x) == f(x), etc.
where f(x) and f2(x) are the functions of x only, and g(y) and g2(y)
are the functions of y only. d(y)/d(x) is used as y', and d(y) and d(x)
can be separated in differential equations. d(d(y)/d(x))/d(x) is used
as y".
Example: solve 5*x^4 + y*d(y)/d(x)==0 where y=f(x).
Input:
5*x^4 + y*d(y)/d(x)==0
last*d(x)
inte(last)
last-x^5
last*2
sqrt(last)
Output:
5*x^4 + y*d(y)/d(x)==0
5*x^4*d(x) + y*d(y) == 0
x^5 + (1/2)*y^2 == Constant
(1/2)*y^2 == Constant - x^5
y^2 == 2*(Constant - x^5)
y == sqrt(2*(Constant - x^5))
For example: solve a second order differential equation
y*y'' == exp(x).
Input:
y*d(d(y)/d(x))/d(x) == exp(x)
inte(last*d(x))
inte(last*d(x))
last*6
last^(1/3)
Output:
y*d(d(y)/d(x))/d(x) == exp(x)
(1/2)*y^2 *d(y)/d(x) == Constant + exp(x)
(1/6)*y^3 == Constant + Constant*x + exp(x)
y^3 == 6*Constant + 6*Constant*x + 6*exp(x)
y == (6*Constant + 6*Constant*x + 6*exp(x))^(1/3)
The function
solve(d(y)/d(x)+g(x)*y == h(x), y)
can solve first order linear differential equation d(y)/d(x)+g(x)*y==h(x)
on one step.
Input:
solve(d(y)/d(x)+sinh(x)*y == sinh(x)*cosh(x), y)
Output:
y == (constant + exp(cosh(x)) - cosh(x)*exp(cosh(x)))*exp(-cosh(x))
15.9 Sums and Products
Users can compute partial, finite or infinite sums and
products. Sums and products can be differentiated and integrated. You
construct functions like Taylor polynomials or finite Fourier series.
The procedure is the same for sums as products so all examples will
be restricted to sums. The general formats for these functions are:
sum(expr, x from a to b step c)
prod(expr, x from a to b step c)
The expression expr is evaluated at a, a+c, ... up to the last
entry in the series not greater than c, and the resulting values
are added or multiplied. The part "step c" is optional and
defaults to 1. The values of a, b and c can be any real number.
Here are some examples:
sum(j, j from 1 to 10)
for 1 + 2 + .. + 10.
sum(3^j, j from 0 to 10 step 2)
for 1 + 3^2 + ... + 3^10.
Here are some sample Taylor polynomials:
sum(x^j/j!, j from 0 to n)
for exp(x).
sum((-1)^j*x^(2*j+1)/(2*j+1)!, j from 0 to n)
for sin(x) of degree 2*n+2.
The library file SUM.LI should be read before computing
partial and infinite sums, and the library file PRODUCT.LI should be
read before computing partial and infinite products.
Remember, the keywords "from", "to" and "step" can be
replaced by commas.
15.10 Series
Example: find the power series expansion for cos(x) about
the point x=0 to order x^4.
Input:
sum(d(cos(x), x=0, n)*x^n/n!, n from 0 to 4)
Output:
1 - (1/2)*x^2 + (1/24)*x^4
Define the TAYLOR function for Taylor series at x=0, then call
TAYLOR().
Input:
define(TAYLOR(y, n)=sum(d(y, x=0, k)*x^k/k!, k from 0 to n))
TAYLOR(cos(x), 4)
Output:
defined
1 - (1/2)*x^2 + (1/24)*x^4
15.11 Lists, Arrays, Vectors and Matrices
SymbMath can construct lists of arbitrary length, and the
entries in the lists can be of any type of value whatsoever:
constants, expressions with undefined variables, or even other lists.
Lists are another kind of value in SymbMath, and they can be assigned
to variables just like simple values. (Since variables in SymbMath
language are untyped, you can assign any value to any variable.).
15.11.1 Entering Lists
To define a list, put its elements between square brackets:
a = [1,2,3]
b = [f(2), g(1), h(1)] # assumes f,g,h defined
c = [[1,2],3,[4,5]]
A function can have a list for its value:
f(x) = [1,x,x^2]
You can define lists another way, with the list command:
list(f(t), t from a to b step c)
This is similar to the sum command, but the result is a list:
[f(a), f(a+c), ..., f(a+j*c), ...]
which continues until the last value of a + j*c <= b .
Try
a = list(j^2, j from 0 to 10 step 1)
f(x) = list(x^j, j from 0 to 6 step 1)
b = f(-2)
The third way to construct a list is to transform the sum to
the list.
Input:
y1=[a,b,c]
sum(y1)+d
list(last)
Output:
y1 = [a, b, c]
a + b + c + d
[a, b, c, d]
This is how you extend an existing list to include a new
element.
15.11.2 Accessing Lists
To find the value of the j-th element in a list x, use the
formula x[j]. The first element of x is always x[1]. If the x[j]
is itself a list, then its k-th element is accessed by repeating the
similar step. Try:
Input:
x = [[1,2],3,[4,5]]
x[1]
x[2]
Output:
x = [[1, 2], 3, [4, 5]]
[1, 2]
3
An entire sub-list of a list x can be accessed with the
command x[j], which is the list:
[x[j], x[j+1], ... ]
15.11.3 Modifying Lists
The function subs() substitutes the value of the element in
the list, as in the variables. e.g.
Input:
l=[a,b,c]
subs(a=a2 to l)
Output:
l = [a, b, c]
[a2, b, c]
But you can't use this form unless the element of the list is
already defined.
15.11.4 List Operations
Lists can be added, subtracted, multiplied, and divided by
other lists or by constants. When two lists are combined, they are
combined term-by-term, and the combination stops when the shortest
list is exhausted. When a scalar is combined with a list, it is
combined with each element of the list. Try:
a = [1,2,3]
b = [4,5,6]
a + b
a / b
3 * a
b - 4
Example:
Input:
list1=[a1,a2,a3]
list2=[b1,b2,b3]
list1+list2
last[1]
Output:
list1 = [a1,a2,a3]
list2 = [b1,b2,b3]
[a1 + b1, a2 + b2, a3 + b3]
a1 + b1
If L is a list, then f(L) results in a list of the values
f(L[i]), even though f() is differentiation d() or integration inte().
Try series with:
Input:
sqrt([a, b, c])
d([x, x^2, x^3]/d(x))
You can sum all the elements in a list x with the commands:
sum(x)
If you use a list as the value of a variable in a user-
defined function, SymbMath will try to use the list in the
calculation.
Example:
x=[1,2,3]
sum(x^2)
This functions takes the sum of the squares of the elements of
the list x.
15.11.5 Vector Operations
Vectors and matrices can be operated by "+" and "-" with vectors
and matrixes, by "*" and "/" with a scalar, and by subs(), diff() and
inte(). These operations are on each element, as in lists and arrays.
You can use lists as vectors, adding them and multiplying them
by scalars. For example, the dot product of two vectors of a and b is:
dot = sum(a*b)
You can even make this into a function:
Dot(x,y) = sum(x*y)
a = [2,3,5]
b = [4,3,2]
Dot(a,b)
How about the cross product:
Cross(a,b) = [a[2]*b[3]-b[2]*a[3],a[3]*b[1]-b[3]*a[1],a[1]*b[2]-b[1]*a[2]]
15.12 Complex Analysis
The complex numbers, complex infinity and some complex
functions can be calculated, and the complex expressions can be
differentiated and integrated.
Sign of complex numbers is defined as
/ 1 (i.e. z>0 ) if re(z)>0, or re(z)=0 and im(z)>0,
sgn(z) = 0 if z=0,
\ -1 (i.e. z<0 ) otherwise.
Example:
Input:
sgn(1+i)
sgn(1-i)
sgn(-1-i)
Output:
1
1
-1
Input:
exp(inf+pi*i)
ln(last)
Output:
-inf
inf + pi*i
Input:
inte(1/x, x from i to 2*i)
Output:
ln(2)
15.13 Tables of Function Values
If you want to look at a table of values for a formula, you
can use the table command:
table(f(x), x from a to b step dx)
It causes a table of values for f(x) to be displayed with x=a,
a+dx, ..., b. You can specify a function to be in table(),
Example:
Input:
table(x^2, x from 0 to 10 step 1)
Output:
0, 0
1, 1
2, 4
: :
: :
Its output can be written into a disk file for interface
with other software (e.g. the numeric computation software).
15.14 Transformation and Piece of Expressions
Different types of data may be transformed each other.
The complex number z is transformed to the real number x by
re(z), im(z), abs(z), sgn(z).
The functions
left() and right()
pick up one side of the equation.
A list is transformed to a sum by
sum(List_Expr)
A sum is transformed to a list by
list(Sum_Expr)
e.g.
Input:
[a, b*x, c*x^2]
sum(last)
list(last)
Output:
[a, b*x, c*x^2]
a + b*x + c*x^2
[a, b*x, c*x^2]
A list can be transformed to a table with the table command if
the elements of the list are the numbers. e.g.
Input:
x=[5,4,3,2,1]
table(x[j], j from 1 to 4 step 1)
Output:
1, 5
2, 4
3, 3
4, 2
A piece of an expression can be picked up. e.g.
Input:
y=a+b*x+c*x^2+d*x^3
coef(y, x)
coef(y, x^2)*x^2
list(y)
last[3]
Output:
y = a + b*x + c*x^2 + d*x^3
b
c*x^2
[a, b*x, c*x^2, d*x^3]
c*x^2
Table 15.2 Expand and Factor
---------------------------------------------------------------------
Expand Factor
(a+b)^2 a^2+2*a*b+b^2
(a+b)^n a^n+ ...... +b^n n is positive integer
a*(b+c) a*b + a*c
---------------------------------------------------------------------
a+b can be many terms or a-b.
15.15 Chemical Calculation
SymbMath recognizes 100 symbols of chemical elements and
converts them into their atomic weights after the chemical library
"Chemical.Li" is run.
Example: calculate the weight percentage of the element C
in the molecule CH4.
Run the library file "Chemical.Li", then
Input:
Numerical=On
C/(C+H*4)*100*%
Output:
74.868 %
Example: calculate the molar concentration of CuO when 3
gram of CuO is in 0.5 litre of a solution.
Input:
Numerical=On
g=1/(Cu+O)*mol
3*g/(0.5*l)
Output:
0.07543 mol/l
15.16 Chemical Reactions
SymbMath can provide the answers for inorganic chemical
reactions after the inorganic reaction library "Inorgani.Li" is run,
and for organic chemical reactions after the organic reaction library
"Organic.Li" is run.
Example: what are the products when the reactors are HCl +
NaOH ?
Run the library file "Inorgani.Li", then
Input:
HCl+NaOH
Output:
H2O + NaCl
15.17 Learning from Users
The most important feature of SymbMath is that SymbMath can
learn from users to deduce and expand its knowledge. If users provide
the necessary facts, then SymbMath can solve many problems it could
not do before.
15.17.1 Learning complicated indefinite integrals from a
simple indefinite integral
Users supply a simple indefinite integral, and then ask many
complicated indefinite integrals.
Example. Users show that an indefinite integral
of tan(x)^2 is tan(x)-x, then ask indefinite integral of
2*tan(x)^2+x, and a double indefinite integral of tan(x)^2+y respect
with both x and y.
Input:
inte(tan(x)^2*d(x))
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))
Output:
inte(tan(x)^2*d(x))
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))
The input are to check whether SymbMath had already known these
integrals or not (i.e. to check if these integrals had already been
stored in the data base or knowledge base, these checking would be
omitted if users trust SymbMath without these predefined knowledge).
On this time, only change the first line, and then run again.
Input:
inte(tan(x)^2*d(x)) = tan(x) - x
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))
The first input line is to teach SymbMath the indefinite integral of
tan(x)^2. The second and third input lines are to ask the indefinite
integral of 2*tan(x)^2+x and the double indefinite integral of
tan(x)^2+y.
Output:
inte(tan(x)^2*d(x)) = tan(x) - x
2 (tan(x) - x) + (1/2)*x^2
tan(x)*y - x*y + x*y^2
Users will ask inte(inte(tan(x)^2+y^2)*d(x))*d(y)),
inte(inte(tan(x)^2*y)*d(x))*d(y)), inte(x*tan(x)^2*d(x)),
triple integral of tan(x)^2-y+z, or others.
15.17.2 Learning definite integral from indefinite integral
Users continue to ask definite integrals as well.
Input:
inte(inte(tan(x)^2+y, x from 0 to 1), y from 0 to 2)
Output:
2 tan(1)
Why does SymbMath become to have these knowledge ? Because
SymbMath logically deduces these integrals from inte(tan(x)^2*d(x)).
This is learning from users.
Notice that SymbMath has not had knowledge of all of these
integrals before. Users did nothing, except for only telling SymbMath
one simple indefinite integral of tan(x)^2, did not tell SymbMath
anything about other indefinite integral (e.g. tan(x)^2+y, tan(x)^2+x,
etc.), an indefinite double integral, definite integral, or definite
double integral, did not write any code (a function, procedure or
subroutine), did not load any file, did not call any subroutine.
15.17.3 Learning complicated derivative from simple
derivative
Input:
d(Ci(x)/d(x))
d((Ci(x)^6)/d(x))
Output:
d(Ci(x)/d(x))
d((Ci(x)^6)/d(x))
Now, only change the first line, and then run again.
Input:
d(Ci(x)/d(x))=cos(x)/x
d((Ci(x)^6)/d(x))
Output:
d(Ci(x)/d(x)) = cos(x)/x
6 Ci(x)^5*cos(x)/x
15.17.4 Learning integration from derivative
If users input derivatives, SymbMath can deduce integrals from
derivatives. e.g. users enter d(Si(x)/d(x))=sin(x)/x, d(Ci(x)/d(x))=
cos(x), then ask the integral of sin(x)/x^3.
Input:
d(Si(x)/d(x))=sin(x)/x
d(Ci(x)/d(x))=cos(x)/x
inte(sin(x)/x^3*d(x))
output:
d(Si(x)/d(x)) = sin(x)/x
d(Ci(x)/d(x)) = cos(x)/x
SymbMath have learned to solve these problems, even although
the problems are different.
15.17.5 Learning integration from algebra
If users tell SymbMath algebra, SymbMath can learn integrals
from algebra. e.g. users show sin(x)^2=1/2-1/2*cos(2*x), then ask
integral of sin(x)^2.
Input:
sin(x)^2=1/2-1/2*cos(2*x)
inte(sin(x)^2*d(x))
Output:
sin(x)^2 = 1/2-1/2*cos(2*x)
(1/2)*x - (1/4)*sin(2*x)
15.17.6 Learning complicated algebra from
simple algebra
Input:
sin(x)/cos(x)=tan(x)
x+sin(x)/cos(x)
Output:
sin(x)/cos(x) = tan(x)
x + tan(x)
Learning is different from programming. On learning, although
users only input one formula, SymbMath will learn many knowledge.
SymbMath is able to learn, as a student does. On programming, users
have many things to do. First, users define many subroutines for the
individual integrands (e.g. tan(x)^2, tan(x)^2+y^2, 2*tan(x)^2+x,
x*tan(x)^2, etc.), and for individual integrals (e.g. the indefinite
integral, definite integral, the indefinite double integrals,
indefinite triple integrals, definite double integrals, definite
triple integrals, etc.), second, write many lines of program for the
individual subroutines, (i.e. to tell the computer how to calculate
these integrals), third, load these subroutines, finally, call these
subroutines.
On other word, programming means that programmers must
provide step-by-step procedures telling the computer how to solve
each problems. By contrast, learning means that users need only supply
the necessary facts, SymbMath will determine how to go about
solutions.
The learning can be saved into a disk as a disk file, so that
SymbMath will never forget it, otherwise SymbMath will forget the
learning when the computer power is off.
16. Interface with Other Software
SymbMath can be interfaced with other software, (e.g. the
numerical calculation, data analysis, graph, and plot software, etc.).
16.1 With PlotData for Graph
If SymbMath is interfaced with the software PlotData, SymbMath
produces the data table of functions, and PlotData plots from the
table, as SymbMath seems to do graphics. This interface can be used
to solve equations graphically.
e.g. plot f(x)=2*x^2 in the range of x from 0 to 40 by
following steps:
1) Write a line of program with table() in the Editor:
table(2*x^2, x from 0 to 40 step 1)
2) Select the command "To disk" in the "Output" menu to force
output to the disk file.
3) Run the program.
4) Select the command "Off disk" in the "output" menu to
return control to the window.
5) Select the command "OS shell" in the "File" menu, then type
PlotData in the input window.
in the software PlotData, just read and plot. PlotData read the data
in the SymbMath format without any modification (and in many data
format). Refer to PlotData for detail.
17. Inside SymbMath
As an expert system, SymbMath consists of three major
components: a knowledge base, an inference engine, and a global data
base. The knowledge base is a set of rules, the inference engine is a
rule interpreter for utilizing the knowledge base in the solution of
the problem, and the global data base is a working memory for keeping
track of the problem status, the data from the data file for the
particular problem, and the solution of sub-problems. In addition, it
contains a natural language interface for input and output natural
languages (e.g. mathematical formulas, chemical reactions).
User Library disk
/|\ | /|\
| | |
\|/ \|/ \|/
------------------------------
| Natural Language Interface |
------------------------------
/|\
|
\|/
------------------------------
------->| Inference Engine |<----------
| ------------------------------ |
\|/ \|/
------------------ --------------------
| Knowledge Base | | Global Data Base |
------------------ --------------------
/|\
|
--------------------
| Data File |
--------------------
Figure 17.1 Base structure of SymbMath
Table 17.1 Characteristics of SymbMath
--------------------------------------------------------------------
Function: Symbolic computation.
Domain: Mathematics, chemistry.
Search direction: Forward chaining.
Control mechanism: Guessing and test, pattern match.
Search space transformations: Break into sub-problems.
Knowledge base representation: Rules.
Developer interface: Library, programming.
End user interface: Pull-down menu, pop-up menu, twin screen
text editor, help.
System interface: numeric computation software, graphic
software (e.g. PlotData), etc.
Input format: Math formulas, numbers, Q-BASIC or FORTRAN
codes, chemical symbols and reactions.
Output format: Math notation, Q-BASIC, FORTRAN, chemical
reactions.
Input from: Keyboard, disk.
Output to: Screen, disk, printer.
Tool language: Prolog.
Computer: IBM PC.
Memory: 640 KBytes.
Operating system: MS-DOS.
---------------------------------------------------------------------
18. System limits
1. The maximum character of a symbol is 127.
2. The maximum character of an output expression is 64,000.
3. The range of the input real numbers is
-inf, -(10^307)^(10^307) to -(10^-307)^(10^-307), 0, (10^-307)^(10^-307)
to (10^307)^(10^307), inf.
4. The range of the output real numbers is the same as input
when the switch Numerical=Off, but when the switch Numerical=On, it is
-inf, -1.E307 to -1.E-307, 0, 1.E-307 to 1.E307, inf.
5. The maximum digit of the input numbers is 127.
6. The maximum digit of the stored numbers is 16.
7. The maximum digit of the output numbers is 11.
19. Future
In the later version, SymbMath will do
1. More functions.
2. Precision calculation: the maximum digit of the output number is
64000.
3. Solving differential equations by Laplace transform.
20. Keywords
SymbMath has three versions. Shareware and Student Versions
are lack some functions, (see the document file SymbMath.DOC for
detail). The following special symbols (about 110 words) are reserved:
20.1 A list of keywords in alphabetical order
----------------------------------------------------------------------
abs, acos, acosh, acot, acoth, acsc, acsch, asec, asech, asin,
asinh, assume, assumed, atan, atanh,
BASIC,
clear, clear_all, cleared, coef, complex, constant, cos, cosh, cot,
coth, csc, csch,
d, define, defined, deno, discont, done,
E, e, end, erf, exp, expand, ExpExpand,
fac, factor, FORTRAN, from,
i, im, inf, inte,
last, left, lim, list, ln, LnExpand,
nume, Numerical, NumIntegrate,
Off, On, Output,
pi, prod, PASICAL,
re, read, real, right,
sec, sech, show_all, sgn, sin, sinh, solve, sqrt, subs, sum, step,
system,
table, tan, tanh, to, TwoDim,
undefined,
zero,
+, -, *, /, ^, **, (), [], =, ==, >, >=, <, <=, <>, !, #, ,
-----------------------------------------------------------------------
20.2 A list of keywords in functional order
---------------------------------------------------------------------
1. Built-in constants: i, e, pi, inf, zero, constant, discont,
undefined.
2. Built-in variables: last.
3. Negative and positive: -, +.
4. Algebraic operators: +, -, *, /, ^, **, (), =, ==.
5. Logic operators: ==, >, >=, <, <=, <>.
6. Algebraic functions: -x, sqrt(x), sgn(x), abs(x), n!, fac(n).
7. Exponential functions: exp(x), ln(x), erf(x).
8. Trigonometric functions: sin(x), cos(x), tan(x), csc(x), sec(x),
cot(x), asin(x), acos(x), atan(x), acot(x), asec(x), acsc(x).
9. Hyperbolic functions: sinh(x), cosh(x), tanh(x), csch(x), sech(x),
coth(x), asinh(x), acosh(x), atanh(x), acoth(x), acsch(x),
asech(x).
10. User-defined functions: define(f(x)=x^2).
11. Calculus functions: d((y)/d(x)), inte((y)*d(x)), subs(x=a to y),
lim(x=a, y), sum(), prod().
12. Transformation functions: list(), expand(), factor(), solve(),
table(), coef(), left(), right(), nume(), deno(), re(), im().
13. List: [a, b].
14. Element of list: f[1], last[1].
15. Switches: =, Numerical, NumIntegrate, Output, On, Off, BASIC,
FORTRAN, TwoDim, ExpExpand, LnExpand.
16. Commands: system(), clear(), clear_all, show_all.
17. Separators: "," , from, to, step.
18. Assume: assume(a>0), assume(b==real).
19. Define: define(f(x)=x^2).
20. Comment: #.
21. Action: defined, done, cleared, assumed.
--------------------------------------------------------------------
20.3 Keywords Dictionary
--------------------------------------------------------------------
abs(x)
The absolute value function of x. e.g. abs(-1) gives 1.
acos(x)
The arc cosine function of x, the inverse function of cos(x).
The result is in radians.
acosh(x)
The arc hyerbolic cosine function of x, the inverse function of
cosh(x).
acot(x)
The arc cot function of x, the inverse function of cot(x).
The result is in radians.
acoth(x)
The arc coth function of x, the inverse function of coth(x).
acsc(x)
The arc csc function of x, the inverse function of csc(x).
The result is in radians.
acsch(x)
The arc csch function of x, the inverse function of csch(x).
asec(x)
The arc sec function of x, the inverse function of sec(x).
The result is in radians.
asech(x)
The arc sech function of x, the inverse function of sech(x).
asin(x)
The arc sine function of x, the inverse function of sin(x).
The result is in radians.
asinh(x)
The arc sinh function of x, the inverse function of sinh(x).
assume()
Assume a variable x to be positive, negative or real. All variables
are assumed as complex by default.
e.g. assume(x>0), assume(x<0), or assume(x == real).
assumed
It points out that the variable has been assumed.
atan(x)
The arc tan function of x, the inverse function of tan(x).
The result is in radians.
atanh(x)
The arc tanh function of x, the inverse function of tanh(x).
BASIC
Output in BASIC format. e.g. Output=BASIC.
clear()
Clear a variable, function or expression from memory. e.g. clear(p),
clear(f(x)).
clear_all
Clear all from memory.
cleared
It says that the variable, function or expression has been cleared
from memory.
coef(poly, x^n)
The coefficient function of x^n. It gives the coefficient of x^n in
the polynomial. e.g. coef(2*x^6+x+4, x^6) gives 2.
constant
The indefinite integral constant.
cos(x)
The cosine function of x. The angle x is measured in radians.
cosh(x)
The hyerbolic cosine function of x.
cot(x)
The cotan function of x. The angle x is measured in radians.
coth(x)
The hyerbolic cosine function of x, i.e. (exp(x)+exp(-x))/2.
csc(x)
The angle x is measured in radians.
csch(x)
d()
The derivative function.
d(f(x), x=c) gives the derivative of f(x) with respect to an
undefined variable x at x=c.
d(f(x), x=c, n) gives the n-th order derivative of f(x) with respect
to an undefined variable x at x=c.
d(f(x)/d(x)) differentiate y with respect to x.
e.g. d(x^2/d(x)) gives 2*x.
d(f(x)/d(x), n) gives the n-th order derivative of f(x) with respect
to an undefined variable x.
d(y) implicit differentiation, used in differential
equations, e.g. x*d(x)+y*d(y) == 0.
define()
Define an user function. e.g. define(f(x)=x^2).
defined
It indicates that the user function has been defined.
deno()
It gives the denominator of expr. e.g. deno(a/b) gives b.
discont
The discontinuity. If the function value is discont, the function has
a discontinuity and only has the one-sided limit at x=c. Users should
evaluate its left-sided limit or right-sided limit by x=c-zero or
x=c+zero.
done
It indicates that the action has been done.
system(system command)
execute operating system (DOS) command. e.g. system(dir).
E
The exponential part of a floating point number. e.g. 1.1E2.
e
(1) 2.718..., the built-in constant, e is converted to 2.718... when the
switch Numerical=On.
(2) The exponential part of a floating point number, the same as E.
e.g. 1.1e2.
erf(x)
The error function of x, or the probability integral function.
exp(x)
The exponential function of x based of e. The same as e^x, e=2.718...
It is the inverse to ln(x).
ExpExpand
The switch of exponential expansion.
ExpExpand=On e.g. c^(a+b) to c^a*c^b.
ExpExpand=Off disable exponential expansion, this is default.
expand(expr)
The expansion function. The expand(expr) is to expand expr, e.g.
expand((a+b)^2) gives a^2 + 2*a*b + b^2.
fac(n)
The factorial of n. The same as n!. e.g. fac(3) gives 6.
factor(expr)
The factorisation function. The factor(expr) is to factorise from
expr, e.g. factor(a^2 + 2*a*b + b^2) gives (a+b)^2.
FORTRAN
Output in FORTRAN format. e.g. Output=FORTRAN.
from
The separator, the same as the comma (,).
i
The imaginative sign of the complex number. e.g. 1+2*i.
im(x)
The imaginative part of complex numbers. e.g. im(1+2*i) gives 2.
inf
The positive infinity, as the built-in constant.
inte()
The integral function.
inte(f(x),x,a,b) find the definite integral of f(x) with respect to
an undefined variable x taken from x=a to x=b.
inte(f(x), x from a to b) the same as inte(f(x),x,a,b).
inte(f(x)*d(x)) find the indefinite integral of f(x) with respect
to an undefined variable x.
inte(y) implicit integration, used to integrate the
differential equations.
last
The last output, as the built-in variable.
last[1] the first element of the last output list.
left(equation)
It gives the left hand side of an equation. e.g. left(x+y==2)
gives x+y.
lim()
The limit function.
lim(x=c, expr) gives the limit of expr when x approaches c.
lim(x=c to expr) the same as lim(x=c, expr).
e.g. lim(x=0, sin(x)/x) gives 1.
Note that the correct answers only for the indeterminate forms:
0/0, inf/inf, 0*inf, 0^0, inf^0.
list()
The list function.
list(f(x), x from a to b step c) lists of f(x),
e.g. list(x^2, x from 1 to 3 step 1)
gives [1,4,9].
list(a+b) transform sum to list, e.g. list(a+b) gives [a,b].
ln(x)
The natural logarithmic function of x. Its base is e. It is the
inverse to exp(x). Warming that if it has multi-values, the ln(x)
only gives a principle value (P.V.) and other values are
P.V.+2*k*pi*i (where k=0, 1, 2,..., -1, -2, ...).
LnExpand
The switch of the logarithmic expansion.
LnExpand=On log expansion, e.g. ln(a*b) is expanded into
ln(a)+ln(b).
LnExpand=Off disable log expansion, this is default.
n!
The factorial of n. The same as fac(n). e.g. 3! gives 6.
nume()
It gives the numerator of expr. e.g. nume(a/b) gives a.
Numerical
The switch of numerical calculation.
Numerical=On numerical computation.
Numerical=Off disable numerical computation, this is default.
NumIntegrate
The switch of numeric integration.
NumIntegrate=On numeric integration.
NumIntegrate=Off disable numeric integration, this is default.
Off
When the switch is set to Off, it is inactive. e.g. Numerical=Off,
Output=Off, NumIntegrate=Off, Expand=Off.
On
When the switch is set to On, it is active. e.g. Numerical=On,
NumIntegrate=On, Expand=On, ExpExpand=On, LnExpand=On.
Output
The switch of the output format, e.g. Output=BASIC, Output=FORTRAN,
Output=PASCAL, Output=TwoDim, or Output=Off.
to
The separator, the same as the comma (,).
pi
3.1416..., as the built-in constant, pi is converted to 3.1416... when
the switch Numerical=On.
prod()
The product function.
prod(f(x), x from a to b step c) product of f(x).
prod(f(x), x from a to b) product of f(x) as step=1.
re(x)
The real part of complex numbers. e.g. re(1+2*i) gives 1.
real
Assume a variable x to be real. e.g. assume(x == real).
right(equation)
It gives the right hand side of an equation. e.g. right(x+y==3)
gives 3.
sec(x)
The angle x is measured in radians.
sech(x)
show_all
Show all in memory.
sgn(x)
The sign function of x. It is 1 when Re(x) > 0, or Re(x) = 0 and
Im(x) > 0; 0 when x=0; -1 otherwise.
sin(x)
The sine function of x. The angle x is measured in radians.
sinh(x)
The hyerbolic sine function of x, i.e. (exp(x)-exp(-x))/2.
solve(equation, unknown)
Solve a polynomial, systems of linear equations, linear differential
equations. e.g. solve(x^2+5*x+6==0, x), solve([x+y==3,x-y==1], [x,y]),
solve(d(y)/d(x)+x*y==2, y).
sqrt(x)
The square root function of x. It is the same as x^0.5.
subs(x=c to expr)
Substitutes x by c in expr. subs(x=c, expr) is the same
as subs(x=c to expr). e.g. subs(x=a to x^2) gives a^2.
sum()
The sum function.
sum(f(x), x from a to b step c) sum of f(x), e.g.
sum(2^n, n from 1 to 10 step 1.2).
sum(f(x), x from a to b) sum of f(x) as step=1, e.g.
sum(2^n, n from 1 to 10).
sum([a,b]) transform list to sum, e.g. sum([a,b]) gives a+b.
step
The separator, the same as the comma (,).
table()
Produce a table of the function values.
table(f(x), x from a to b step c) data table.
e.g. table(x^2, x from 1 to 20 step 2).
tan(x)
The angle x is measured in radians.
tanh(x)
TwoDim
Output in two dimension format. e.g. Output=TwoDim.
undefined
The built-in constant. It indicates that the value of the expression
is undefined. e.g. the indeterminate forms: 0/0, inf/inf, 0*inf, 0^0.
Users should try again by lim(x=c, f(x)).
zero
The right-hand sided value at x=0, as the built-in constant. -zero
is the left-sided limit from the negative direction. e.g. 1+zero is
to approach to 1 from the positive (+infinity) direction (the right-
hand sided value), and 1-zero is to approach to 1 from the negative
(-infinity) direction (the left-hand sided value), i.e. limit as
zero -> 0. e.g. exp(1/(0+zero)) gives inf, exp(1/(0-zero)) gives 0.
+ add or positive sign.
- subtract or negative sign.
* multiply.
/ divide.
^ power in BASIC, the same as ** in FORTRAN, e.g. 2^3 gives 8.
** power in FORTRAN, the same as ^ in BASIC.
! factorial, the same as fac(x), e.g. 3! or fac(3) gives 6.
< less than.
<= less than.
> greater than.
>= greater than.
<> unequals.
== equals, or equation sign.
= assignment.
, separator.
# comment statement.
-------------------------------------------------------------------------
21. References
[1] Buchberger, B., Collins, G.E., and Loos, R., Computer Algebra,
Springer-Verlag, New York, 1983, pp. 4-7.
[2] Oman, P., IEEE Software, 1990, Vol. 7, pp. 93-95, pp. 98.
[3] Calmet, J., Int. J. Math. Educ. Sci. Technol., 1987, 18(5), 663-680.
[4] Raeth, P.G., Expert Systems: A Software Methodology for Modern
Applications, IEEE Computer Society Press, Washington, 1990, pp.
17-51.
[5] Huang, W., Proceedings of the Workshop on Symbolic and Numeric
Computation, Helsinki Uni., Finland, 1991, pp. 185-186.
[6] Huang, W., Int. J. Math. Educ. Sci. Technol., 1992, in press.
[7] Huang, W., Abs. Am. Math. Soc., 1992, 13(3), 343.
[8] Huang, W., Proceeding of 7th Inter. Congress on Math. Educ., Uni.
Laval, Canada, 1992, in press.